package com.gitee.magic.converter;

import java.util.UUID;

import com.gitee.magic.core.converter.AbstractConverterEditor;

/**
 * @author start
 */
public class UUIDConverterEditor extends AbstractConverterEditor<String>  {

	public UUIDConverterEditor(Class<?> prototype) {
		super(prototype);
	}

	@Override
	public void restore(Object value) {
		if(value!=null) {
			setValue(UUID.fromString(String.valueOf(value)));
		}
	}

	@Override
	public String converter() {
		UUID value = (UUID) getValue();
		return (value != null ? value.toString() : null);
	}
	
	@Override
	public Object getSource() {
		return converter();
	}
	
}
